<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
	/*验证码*/
    public function miti()
    {
    	$Verify = new \Think\Verify();
		$Verify->fontSize = 30;
		$Verify->length   = 4;
		$Verify->useNoise = false;
		$Verify->entry();
    }

    public function index(){
        $this->display();
    }
    //登录
    public function signIn(){
    	$arr['name'] = trim(I('post.name'));
    	$arr['password'] = md5(I('post.password'));
    	$arr['code'] = I('post.code');
    	
    	$adminModel = D('Admin');
    	$res = $adminModel->signIn($arr);

    	if($res == 'onEq') 
        {
            $this -> error('验证码不正确！');
        }elseif($res == 'err')
        {
            $this->error('账号或密码不正确！');
        }else
        {
            session('admin_id',$res['0']['admin_id']);
            session('name',$res['0']['name']);
            session('power',$res['0']['power']);
            $this -> success('登录成功！',  __APP__.'/Home/Index/index');

        }
    }

    /*退出*/
    public function signOut()
    {
    	session('admin_id', 0);

        $this->success('已退出登录！', __APP__.'/Home/Login/index');
    }
}